import store from '@/store';
import type { MenuDataItem } from '@ant-design/pro-layout';

export const renderMenuDataByRights = (menuData: MenuDataItem[]): MenuDataItem[] => {
    const [state] = store.getModel('user')
    if (state.currentUser.role === 'admin') return menuData
    // 做菜单权限管理
    return menuData.filter(item => {
        if (!item.meta.auth) return true;
        return item.meta.auth.indexOf(state.currentUser.role) > -1;
    })
}